package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-07-12
 * Time: 10:55
 */
//定义一个学生类
class student{
    public int age;
    public String name;

    public void DohomeWork() {
        System.out.println("学生写作业");
    }
    public void Sleep() {
        System.out.println("学生睡大觉");
    }
    public void run() {
        System.out.println("学生上体育课跑步");
    }
}
//定义一个狗类
class Dog {
    public String name;
    public int age;

    public void eat() {
        System.out.println(name+"吃狗粮");
    }
    public void Sleep() {

        System.out.println("睡觉");
    }
}
public class test1 {
    public static void main2(String[] args) {
        //实例化一个对象
        Dog dog = new Dog();//dog叫做引用变量

        //通过对象的引用去访问对象的成员变量，成员方法
        dog.name = "奥比";
        dog.age = 1;
        dog.eat();
        System.out.println(dog.name);
        System.out.println(dog.age);
    }
}
